/**
 *  @author 赵
 *  @description 初始化时间 格式为: 
 */


function getTime() {
    const now = new Date();
    // 获取年
    let year = now.getFullYear(); // 获取年
    let month = now.getMonth()+1; // 获取月
    let day = now.getDate(); // 获取日
    let weekly = now.getDay(); // 获取星期
    let hour = now.getHours(); // 获取小时
    let minute = now.getMinutes(); // 获取分钟
    let second = now.getSeconds(); // 获取秒

    // 判断上下午
    let isNoon = hour >=12 ? "下午" : "上午";

 // 小时换成 12 小时制
 hour = hour<12 ? hour : hour - 12;

    // 月、日初始化 小于10 前面加0 el.6-> 06
 month = month>9 ? month: "0" + month;
 day = day>9 ? day: "0" + day;
 hour = hour = hour>9 ? hour: "0" + hour;
 minute = minute = minute>9 ? minute: "0" + minute;
 second = second = second>9 ? second: "0" + second;

    //星期1 
    switch(weekly) {
        case 1: weekly="一";break;
        case 2: weekly="二";break;
        case 3: weekly="三";break;
        case 4: weekly="四";break;
        case 5: weekly="五";break;
        case 6: weekly="六";break;
        case 0: weekly="日";break;
    }

  return  `当前时间是: ${year}年${month}月${day}日 ${isNoon} ${hour}:${minute}:${second} 星期${weekly}`
}

export default getTime;